﻿using System;
using Caliburn.Micro;

namespace SunXmlEditor.Views
{
  public class AddNameValuePairViewModel : Screen
  {
    public AddNameValuePairViewModel()
    {
      DisplayName = "添加新项";
    }

    private string _XName;

    /// <summary>
    /// 绑定通知，特姓名
    /// </summary>
    public string XName
    {
      get { return _XName; }
      set
      {
        if (_XName == value) { return; }
        _XName = value;
        NotifyOfPropertyChange(nameof(XName));
      }
    }

    private string _XValue;

    /// <summary>
    /// 绑定通知，特性值
    /// </summary>
    public string XValue
    {
      get { return _XValue; }
      set
      {
        if (_XValue == value) { return; }
        _XValue = value;
        NotifyOfPropertyChange(nameof(XValue));
      }
    }

    public void Submit()
    {
      if (!String.IsNullOrWhiteSpace(XName)
        && !String.IsNullOrWhiteSpace(XValue))
      {
        TryClose(true);
      }
    }
  }
}